<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // let age = "my-hello-word"
        // let mm = str.replace('m',"M")
        // let hh = mm.replace('h',"H")
        // let ww = hh.replace('w',"W")
        // let jg = ww.replaceAll("-","")        
        // console.log(jg);
        // -----------------------------------------------
        // let age = "my-hello-word"
        // // console.log(str.replace(/-/g,''));
        // // my hello word    
        // str = str.replace(/-/g," ")
        // // \b 匹配单词 
        // // \d 数字 0-9
        // str = str.replace(/\b\w/g, function () {
        //     return str.toUpperCase()
        // })     

        // str = str.replaceAll(" ",'')
        // console.log(str);
        // --------------------------------------------------
        let age = "my-hello-word"
        let chgWord = (str) => {
            // let str = "MyHelloWord"
            let arr = str.split("-")
            // 单词拿到了，首字母大写，[0]
            for (let i = 0; i < arr.length; i++) {
                // 拿到每个单词
                let word = arr[i]
                // 将首字母大写  截取
                arr[i] = word[0].toLocaleUpperCase() + word.slice(1)
                // console.log(word);
            }
            return arr.join('')
        }
        let ss = chgWord(age)
        console.log(ss);
    </script>
</body>

</html>